var a = getApp();

Page({
    data: {
        sType: "",
        page: 1,
        total_page: 0,
        datas: [],
        loading: !1,
        allLoaded: !1,
        isLoadMore: !0,
        typeData: [],
        popupSpecs: !1
    },
    onLoad: function(a) {},
    onReady: function() {},
    onShow: function() {
        this.setData({
            sType: "",
            page: 1,
            total_page: 0,
            datas: [],
            loading: !1,
            allLoaded: !1,
            isLoadMore: !0,
            typeData: [],
            popupSpecs: !1
        }), this._getData(this.data.sType);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData(this.data.page, this.data.sType) : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    _getData: function(t) {
        var e = this, s = a.getNetAddresss("finance.income.get-income-list");
        s += "&income_type=" + t, s += "&page=" + this.data.page, a._getNetWork({
            url: s,
            success: function(a) {
                var t = a.data;
                1 == t.result && e.setData({
                    total_page: t.data.last_page,
                    datas: t.data.data
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    _getMoreData: function(t, e) {
        var s = this;
        if (this.data.page != this.data.total_page) if (this.data.page >= this.data.total_page) s.setData({
            loading: !0,
            allLoaded: !0
        }); else {
            s.setData({
                page: this.data.page + 1
            });
            var o = a.getNetAddresss("finance.income.get-income-list");
            o += "&income_type=" + e, o += "&page=" + this.data.page, a._getNetWork({
                url: o,
                success: function(a) {
                    var t = a.data;
                    if (1 == t.result) {
                        var e = t.data;
                        s.setData({
                            loading: !1,
                            allLoaded: !1,
                            datas: s.data.datas.concat(e.data)
                        });
                    } else s.setData({
                        page: s.data.page - 1,
                        loading: !0,
                        allLoaded: !0,
                        isLoadMore: !1
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        }
    },
    screen: function() {
        0 == this.data.typeData.length && this._getTypeData(), this.setData({
            popupSpecs: !0
        });
    },
    _getTypeData: function() {
        var t = this, e = a.getNetAddresss("finance.income.get-search-type");
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result && t.setData({
                    typeData: e.data
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    godetailsinfo: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageA/member/income_details_info/income_details_info?id=" + t
        });
    },
    screenType: function(a) {
        var t = a.currentTarget.dataset.type;
        this.setData({
            sType: t,
            popupSpecs: !1
        }), this.initData(), this._getData(this.data.sType);
    },
    initData: function() {
        this.setData({
            page: 1,
            total_page: 0,
            goload: !0,
            loading: !0,
            allLoaded: !1,
            isLoadMore: !0,
            datas: []
        });
    },
    screenTypeClose: function() {
        this.setData({
            popupSpecs: !1
        });
    }
});